/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.wii.elpro.web.action;

import com.wii.elpro.dao.InqueryDAOInterface;
import com.wii.elpro.dao.SpdcfDAOInterface;
import com.wii.elpro.dao.hb.InqueryDAOImpl;
import com.wii.elpro.dao.hb.ScatteredFunction;
import com.wii.elpro.dao.hb.SpdcfDAOImpl;
import com.wii.elpro.entity.User;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import javax.servlet.http.HttpSession;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionForward;

/**
 *
 * @author City_Z
 */
public class SpdcfNewAction extends org.apache.struts.action.Action {
    
    /* forward name="success" path="" */
    private final static String SUCCESS = "success";
    
  
    @Override
    public ActionForward execute(ActionMapping mapping, ActionForm  form,
            HttpServletRequest request, HttpServletResponse response)
             {
        HttpSession sess = request.getSession(true);
        User user = (User)sess.getAttribute("userSession");       
        if(user==null){
            return mapping.findForward("gagalLogin");            
        }  
        InqueryDAOInterface inq = new InqueryDAOImpl();
        SpdcfDAOInterface spdcfDao = new SpdcfDAOImpl();
        try{
            List list = ScatteredFunction.getNewInquiry(inq.getInqueries(), spdcfDao.getSpdcf());
            request.setAttribute("listInquery", list);
        }catch(Exception e){
            e.printStackTrace();
        }
        return mapping.findForward(SUCCESS);
        
    }
}